package com.taotao.interceptor.controller;

import com.taotao.interceptor.entity.UserEntity;
import com.taotao.interceptor.mapper.UserMapper;
import org.apache.catalina.mbeans.UserMBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: wangjin
 * @CreateTime: 2022-08-07  19:19
 */
@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @GetMapping("/getByUserName")
    @Transactional
    public List<UserEntity> getByUserName(String name) {
        List<UserEntity> userList1 = userMapper.getUser2();// 查询db
        List<UserEntity> userList2 = userMapper.getUser2();// 走一级缓存
        return userList2;
    }

    @RequestMapping("insert")
    public String insert(UserEntity userEntity){
        int result=userMapper.insert(userEntity);
      return result>0 ?"OK": "FAIL";
    }
}
